package library.mapper;
import org.apache.ibatis.annotations.Param;

import library.po.Borrow;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface BorrowMapper {
    /**
     * delete by primary key
     * @param borrowId primaryKey
     * @return deleteCount
     */
    int deleteByPrimaryKey(Integer borrowId);

    /**
     * insert record to table
     * @param record the record
     * @return insert count
     */
    int insert(Borrow record);

    /**
     * select by primary key
     * @param borrowId primary key
     * @return object by primary key
     */
    Borrow selectByPrimaryKey(Integer borrowId);

    /**
     * update record
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKey(Borrow record);
    /**
     * 通过userId查记录
     * @param userId
     * @return borrowList
     */
    List<Borrow> selectByUserId(String userId);
    /**
     * 续借
     * @param borrowId
     * @int update count
     */
    int renew(int borrowId);

    /**
     * 通过userid/书名/借阅状态进行模糊查询
     * @param str
     * @return
     */
    List<Borrow> selectBorrow(@Param("str")String str);

    /**
     * 查询所有借阅记录
     * @return list
     */
    List<Borrow> selectAllBorrow();

    /**
     * 归还图书
     * @param record
     * @return
     */
    int returnBook(Borrow record);
}